<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2019-04-08
  Time: 16:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>index</title>
    <script src="js/jquery-3.0.0.js"></script>
</head>
<body>
index!!!!!!!!!!!!!<br>
<button onclick="getVip()">获取</button>

<div>
    <table id="box" class="tab">
        <tr>
            <td>姓名</td>
            <td>年龄</td>
            <td>性别</td>
        </tr>
    </table>
</div>
</body>

<script type="text/javascript">
    $(function () {
        console.log("start!");
    });
    
    function getVip() {
        $.ajax({
            url: "vip/getAllVip",//向本地的json文件发送请求
            type: "GET",
            success: function (data) {
                var i;
                var html='';//用一个变量来存储json中的数据
                for (i = 0; i < data.length; i++) { //用for循环遍历数组将数据存入html变量中
                    html += '<tr>' +
                        '<td>'+data[i].name+'</td>'+
                        '<td>'+data[i].age+'</td>'+
                        '<td>'+data[i].sex+'</td></tr>';
                }
                document.getElementById("box").innerHTML += html;
            },
            error: function () {
                //请求失败之后做的事情
            }
        })
    };
</script>
</html>
